package day018.thread.demo7;

public class ProduceTask implements  Runnable{
    @Override
    public void run() {
        while(true){
            synchronized (Resource.LOCK){
                if(Resource.num==0){
                    System.out.println(Thread.currentThread().getName()+" 发现没有食物，开始生产~~");
                    Resource.num=1;
                    Resource.LOCK.notify();
                }else{
                    System.out.println(Thread.currentThread().getName()+" 发现没有食物，等待中...");
                    try{
                        Resource.LOCK.wait();
                    }catch (InterruptedException e){
                        e.printStackTrace();
                    }
                }
            }
        }
    }
}
